   package com.atguigu.webapp.service.impl;

   import com.aliyun.dysmsapi20170525.Client;
   import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
   import com.atguigu.webapp.service.SmsService;
   import lombok.SneakyThrows;
   import org.springframework.beans.factory.annotation.Autowired;
   import org.springframework.stereotype.Service;

   /**
    * @Author 梅超凡
    * @Date 2024/11/12~21:57
    * @Description 短信服务实现类
    */
   @Service
   public class SmsServiceImpl implements SmsService {

       @Autowired
       private Client client;

       @SneakyThrows
       @Override
       public void sendCode(String phone, String verifyCode) {
           SendSmsRequest smsRequest = new SendSmsRequest();
           smsRequest.setPhoneNumbers(phone);
           smsRequest.setSignName("阿里云短信测试");
           smsRequest.setTemplateCode("SMS_154950909");
           smsRequest.setTemplateParam("{\"code\":\"" + verifyCode + "\"}\n");
           client.sendSms(smsRequest);
       }
   }
   